//package com.catl.swap.test.plc4x;
//
//import org.apache.plc4x.java.PlcDriverManager;
//import org.apache.plc4x.java.opm.PlcEntityManager;
//import org.apache.plc4x.java.utils.connectionpool.PooledPlcDriverManager;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
//import java.util.List;
//import java.util.Map;
//
///**
// * @Description TODO
// * @ClassName PLc4xConfig
// * @Date 2021/12/23 10:20
// * @Author 王东平
// */
//@Configuration
//public class PLc4xConfig {
//    private String agreementName = "modbus";
//    private String transport = "tcp";
//    private String ip = "127.0.0.1";
//    private int port = 4250;
//    private int requestTimeout = 5000;
//    /**
//     * 连接参数
//     */
//    private Map<String,String> parameters;
//    /**
//     * 从机号集合
//     */
//    private List<String> slaveIds;
//
//    @Bean
//    public PlcDriverManager plDriverManager() {
//        return new PooledPlcDriverManager();
//    }
//
//    @Bean
//    public PlcEntityManager PlcEntityManager() {
//        return new PlcEntityManager(plDriverManager());
//    }
//
//
//    public String connectStr(String agreementName, String transport, String ip, int port, int requestTimeout, int slaveId) {
//        return agreementName + ":" + transport + "://" + ip + ":" + port + "?request-timeout=" + requestTimeout + "&unit-identifier=+" + slaveId;
//    }
//
//    public String modbusTcpConnectStr(String ip, int port, int requestTimeout, int slaveId) {
//        //String connectStr="modbus:tcp://127.0.0.1:4250?request-timeout=5000&unit-identifier=1";
//        return "modbus:tcp://" + ip + ":" + port + "?request-timeout=" + requestTimeout + "&unit-identifier=+" + slaveId;
//    }
//    public String modbusTcpConnectStr(int slaveId) {
//        //String connectStr="modbus:tcp://127.0.0.1:4250?request-timeout=5000&unit-identifier=1";
//        return "modbus:tcp://" + ip + ":" + port + "?request-timeout=" + requestTimeout + "&unit-identifier=+" + slaveId;
//    }
//}
